<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta property="og:type" content="website">
<meta property="og:title" content="smallmuou&#39;s blog">
<meta property="og:url" content="http://smallmuou.gitee.io/blog/page/13/index.html">
<meta property="og:site_name" content="smallmuou&#39;s blog">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="smallmuou&#39;s blog">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://smallmuou.gitee.io/blog/page/13/"/>





  <title>smallmuou's blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">smallmuou's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"><a href="https://github.com/smallmuou">https://github.com/smallmuou</a></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/04/04/2016-04-04-MacOSX配置ssh服务/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/04/04/2016-04-04-MacOSX配置ssh服务/" itemprop="url">MacOSX配置ssh服务</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-04-04T00:00:00+08:00">
                2016-04-04
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>最近想用公司的一台闲置的Mac-Mini搭建一个服务器，而Mac-Mini没有显示器，因此想通过ssh来登录并进行操作，本文将讲述MacOSX系统如何配置ssh服务.</p>
<h3 id="sshd"><a href="#sshd" class="headerlink" title="sshd"></a>sshd</h3><p>幸运的是，系统已集成sshd命令，大家可以执行下sshd命令，但发现会报出如下错误.</p>
<pre>
StarnetdeMacBook-Pro:weiju-sdk-docs starnet$ sshd
sshd re-exec requires execution with an absolute path
</pre>

<p>含义就是sshd需要绝对路径执行，于是我们使用<code>which sshd</code>查看绝对路径，并执行</p>
<pre>
StarnetdeMacBook-Pro:weiju-sdk-docs starnet$ which sshd
/usr/sbin/sshd
StarnetdeMacBook-Pro:weiju-sdk-docs starnet$ /usr/sbin/sshd
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key
StarnetdeMacBook-Pro:weiju-sdk-docs starnet$ 
</pre>

<p>可是又报出Could not load host key错误. 解决方法:</p>
<pre>
sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
sudo ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
sudo ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
sudo ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key
</pre>

<p>再执行</p>
<p><pre><br>StarnetdeMacBook-Pro:weiju-sdk-docs starnet$ sudo /usr/sbin/sshd<br>StarnetdeMacBook-Pro:weiju-sdk-docs starnet$ ps -e|grep sshd<br>74801 ??         0:00.00 /usr/sbin/sshd<br>74859 ttys001    0:00.00 grep –color sshd<br></pre><br>自此ssh服务已启动，可以通过<code>ssh username@ip</code>进行测试</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/03/22/2016-03-22-可持续化集成Travis-CI入门教程/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/03/22/2016-03-22-可持续化集成Travis-CI入门教程/" itemprop="url">可持续化集成Travis-CI入门教程</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-03-22T00:00:00+08:00">
                2016-03-22
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/版本管理/" itemprop="url" rel="index">
                    <span itemprop="name">版本管理</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p><a href="https://travis-ci.org/smallmuou/travis-ci-tutorial" target="_blank" rel="noopener"><img src="https://travis-ci.org/smallmuou/travis-ci-tutorial.svg?branch=master" alt="Build Status"></a></p>
<p>为了提高团队开发的高效性，要求每位成员提交的代码都是可编译，以保证其他成员更新后能够编译成功；当然如果有单元测试，也需要保证单元测试可通性. 而如果要求团队成员自己来完成这些工作，必然无法保证而且浪费时间. Travis-CI就是为解决这些问题而产生的. Travis-CI是一套依托于Github的可持续集成环境，可以帮助coder进行编译验证及单元测试. 本文将从零开始，为大家展现Travis-CI使用方法.</p>
<h3 id="1-集成步骤"><a href="#1-集成步骤" class="headerlink" title="1. 集成步骤"></a>1. 集成步骤</h3><ul>
<li>进入<a href="https://travis-ci.org" target="_blank" rel="noopener">travis-ci官网</a></li>
<li>点击Sign Up并取得Github授权</li>
<li>点击左侧【My Repositories】的 + 创建可持续化集成</li>
<li>打开您需要构建持续化集成的repo（当然需要在Github中已经存在的，可以点击【Sync account】来刷新）</li>
<li>在您的Github工程中添加.travis.yml文件，如:<pre>
language: c
install:
  - make 
script:
  - "./hello"
</pre></li>
<li>提交并push更新后，可以在travis-ci账号中心的首页参看提交及编译信息.</li>
<li>如果需要在README.md中显示build状态，可以在README.md中添加如下类似信息<br><pre><br>[![Build Status](<a href="https://travis-ci.org/smallmuou/travis-ci-tutorial.svg?branch=master)](https://travis-ci.org/smallmuou/travis-ci-tutorial)" target="_blank" rel="noopener">https://travis-ci.org/smallmuou/travis-ci-tutorial.svg?branch=master)](https://travis-ci.org/smallmuou/travis-ci-tutorial)</a><br></pre><br>PS: 进入travis-ci账号中心首页，点击build状态图标，会出现弹窗口，第二个选择框选择【Markdown】，之后拷贝文本框的内容，黏贴到README.md中即可</li>
</ul>
<p>大家可以访问DEMO: <a href="https://github.com/smallmuou/travis-ci-tutorial" target="_blank" rel="noopener">https://github.com/smallmuou/travis-ci-tutorial</a></p>
<h3 id="2-认识-travis-yml"><a href="#2-认识-travis-yml" class="headerlink" title="2. 认识.travis.yml"></a>2. 认识.travis.yml</h3><p>Travis CI分为2步: install和script</p>
<ul>
<li>install - 环境准备，如生成可执行文件、配置环境变量<ul>
<li>before_install - install前触发</li>
</ul>
</li>
<li>script - 测试脚本 （返回0，表示成功，否则失败）<ul>
<li>before_script - 执行测试脚本前触发    </li>
<li>after_success - 脚本执行成功后触发</li>
<li>after_failure - 脚本执行失败后触发</li>
<li>after_script - 脚本执行后触发</li>
</ul>
</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/03/17/2016-03-17-linphone源码解读之Filter/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/03/17/2016-03-17-linphone源码解读之Filter/" itemprop="url">linphone源码解读之Filter</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-03-17T00:00:00+08:00">
                2016-03-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/音视频/" itemprop="url" rel="index">
                    <span itemprop="name">音视频</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>Filter是linphone源码的精髓，Filter可以比作过滤器，负责对数据进行不同功能的操作，如解码、编码、显示、滤噪等等. 往往一个流程需要很多个Filter来组成，只有经过一层层的过滤，才能得到【纯净】的数据. 比如视频接收显示流程，需要经过rtprecv、decoder、tee、jpegwriter、display几个Filter. 下面我们来详细地讲述Filter.</p>
<h3 id="定义"><a href="#定义" class="headerlink" title="定义"></a>定义</h3><pre>
struct _MSFilterDesc{
    MSFilterId id;
    const char *name;
    const char *text;
    MSFilterCategory category;
    const char *enc_fmt;
    int ninputs;
    int noutputs;
    MSFilterFunc init;
    MSFilterFunc preprocess;
    MSFilterFunc process;
    MSFilterFunc postprocess;
    MSFilterFunc uninit;
    MSFilterMethod *methods;
    unsigned int flags;
};

struct _MSFilter{
    MSFilterDesc *desc; //描述，指定过滤id、名称、函数指针（初始化、预处理、处理、反初始化）
    ms_mutex_t lock;
    MSQueue **inputs; //输入源
    MSQueue **outputs; //输出源
    struct _MSFactory *factory;
    void *padding;
    void *data;
    struct _MSTicker *ticker;
    MSList *notify_callbacks;
    uint32_t last_tick;
    MSFilterStats *stats;
    int postponed_task;
    bool_t seen;
};
</pre>
PS: 每种类型的Filter仅有一个Desc，该Desc定于实现文件中，并通过EXPORT来引用.

### 创建
创建一个Filter的方式比较多，可以根据id、name、desc等等，如下是五种创建方式，足够用.
<pre>
MS2_PUBLIC MSFilter * ms_filter_create_encoder(const char *mime); //创建编码Filter
MS2_PUBLIC MSFilter * ms_filter_create_decoder(const char *mime); //创建解码Filter
MS2_PUBLIC MSFilter *ms_filter_new(MSFilterId id); //根据Id创建Filter
MS2_PUBLIC MSFilter *ms_filter_new_from_name(const char *name); //根据名称创建Filter
MS2_PUBLIC MSFilter *ms_filter_new_from_desc(MSFilterDesc *desc); //根据描述创建Filter
</pre>

<h3 id="连接"><a href="#连接" class="headerlink" title="连接"></a>连接</h3><p>在文章开头我已声明过，一个流程可能会有多个Filter，那么问题来了，我们如何关联这些Filter？这里大家可以想到化学实验课时，我们一般会使用一个导管把上一步的输出接到下一步的输入，这里也一样，我们可以通过ms_filter_link来连接2个Filter.</p>
<pre>
// 连接f1的outputs[pin1]与f2的inputs[pin2]
int ms_filter_link(MSFilter *f1, int pin1, MSFilter *f2, int pin2){
    MSQueue *q; //可以理解为导管
    ...
    q=ms_queue_new(f1,pin1,f2,pin2);
    f1->outputs[pin1]=q;
    f2->inputs[pin2]=q;
    return 0;
}
</pre>

<h3 id="断开"><a href="#断开" class="headerlink" title="断开"></a>断开</h3><p>有连接操作就有断开操作，当需要断开2个Filter又如何操作呢，那就是去掉导管</p>
<pre>
int ms_filter_unlink(MSFilter *f1, int pin1, MSFilter *f2, int pin2){
    MSQueue *q;
    ...
    q=f1->outputs[pin1];
    f1->outputs[pin1]=f2->inputs[pin2]=0;
    ms_queue_destroy(q);
    return 0;
}
</pre>

<h3 id="销毁"><a href="#销毁" class="headerlink" title="销毁"></a>销毁</h3><p>为了保证资源的正确释放，需要调用销毁接口</p>
<pre>
void ms_filter_destroy(MSFilter *f)
</pre>


<h3 id="实例-视频接收显示"><a href="#实例-视频接收显示" class="headerlink" title="实例 - 视频接收显示"></a>实例 - 视频接收显示</h3><h4 id="启动视频"><a href="#启动视频" class="headerlink" title="启动视频"></a>启动视频</h4><p>videostream.c</p>
<pre>
int video_stream_start_with_source (VideoStream *stream, RtpProfile *profile, const char *rem_rtp_ip, int rem_rtp_port,
    const char *rem_rtcp_ip, int rem_rtcp_port, int payload, int jitt_comp, MSWebCam* cam, MSFilter* source, bool_t discard_decode_error){
        ...
        /* 创建 */
        stream->ms.decoder=ms_filter_create_decoder(pt->mime_type);
        if (stream->ms.decoder==NULL){
            /* big problem: we don't have a registered decoderfor this payload...*/
            ms_error("videostream.c: No decoder available for payload %i:%s.",payload,pt->mime_type);
            return -1;
        }
        ...
        /* display logic */
        stream->output = ms_filter_new_from_name (stream->display_name);
        stream->ms.rtprecv = ms_filter_new (MS_RTP_RECV_ID);
        ms_filter_call_method(stream->ms.rtprecv,MS_RTP_RECV_SET_SESSION,stream->ms.sessions.rtp_session);

        if (stream->output_performs_decoding == FALSE) {
            stream->jpegwriter=ms_filter_new(MS_JPEG_WRITER_ID);
            if (stream->jpegwriter){
                stream->tee2=ms_filter_new(MS_TEE_ID);
            }
        }
        ...
        /* 连接 */
        ms_connection_helper_start (&ch);
        ms_connection_helper_link (&ch,stream->ms.rtprecv,-1,0);
        if (stream->output_performs_decoding == FALSE) {
            if (stream->itcsink){
                ms_connection_helper_link(&ch,stream->tee3,0,0);
                ms_filter_link(stream->tee3,1,stream->itcsink,0);
                configure_itc(stream);
            }
            ms_connection_helper_link(&ch,stream->ms.decoder,0,0);
        }
        if (stream->tee2){
            ms_connection_helper_link (&ch,stream->tee2,0,0);
            ms_filter_link(stream->tee2,1,stream->jpegwriter,0);
        }
        if (stream->output!=NULL)
            ms_connection_helper_link (&ch,stream->output,0,-1);
        ...
}
</pre>
PS: tee是一分多过滤器，一个输入多个输出
可以看出视频输出经过的过滤器依次是：ms.rtprecv -》 ms.decoder -》 tee2 -》jpegwriter-》output

ms_connection_helper_link可以理解队列，filter依次加到其尾部

#### 停止视频
videostream.c
<pre>
void
video_stream_stop (VideoStream * stream)
{
...
            } else if (stream->ms.rtprecv){
                MSConnectionHelper h;
                ms_connection_helper_start (&h);
                ms_connection_helper_unlink (&h,stream->ms.rtprecv,-1,0);
                if (stream->output_performs_decoding == FALSE) {
                    if (stream->itcsink){
                        ms_connection_helper_unlink(&h,stream->tee3,0,0);
                        ms_filter_unlink(stream->tee3,1,stream->itcsink,0);
                    }
                    ms_connection_helper_unlink (&h,stream->ms.decoder,0,0);
                }
                if (stream->tee2){
                    ms_connection_helper_unlink (&h,stream->tee2,0,0);
                    ms_filter_unlink(stream->tee2,1,stream->jpegwriter,0);
                }
                if(stream->output)
                    ms_connection_helper_unlink (&h,stream->output,0,-1);
                if (stream->tee && stream->output && stream->output2==NULL)
                    ms_filter_unlink(stream->tee,1,stream->output,1);
            }
        }
    }
...
}
</pre>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/03/11/2016-03-11-关于Gitlab若干权限问题/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/03/11/2016-03-11-关于Gitlab若干权限问题/" itemprop="url">关于Gitlab若干权限问题</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-03-11T00:00:00+08:00">
                2016-03-11
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/版本管理/" itemprop="url" rel="index">
                    <span itemprop="name">版本管理</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>公司切入Gitlab来管理代码已经有一年多了，其中遇到很多权限问题，如没有权限clone、没有权限提交代码等等，这里做个总结. 权限分为访问权限和行为权限两个层次.</p>
<h2 id="访问权限-Visibility-Level"><a href="#访问权限-Visibility-Level" class="headerlink" title="访问权限 - Visibility Level"></a>访问权限 - Visibility Level</h2><p>这个是在建立项目时就需要选定的，主要用于决定哪些人可以访问此项目，包含3种</p>
<ul>
<li>Private - 私有，只有属于该项目成员才有原先查看</li>
<li>Internal - 内部，用个Gitlab账号的人都可以clone</li>
<li>Public - 公开，任何人可以clone</li>
</ul>
<h2 id="行为权限"><a href="#行为权限" class="headerlink" title="行为权限"></a>行为权限</h2><p>在满足行为权限之前，必须具备访问权限（如果没有访问权限，那就无所谓行为权限了），行为权限是指对该项目进行某些操作，比如提交、创建问题、创建新分支、删除分支、创建标签、删除标签等.</p>
<h3 id="角色"><a href="#角色" class="headerlink" title="角色"></a>角色</h3><p>Gitlab定义了以下几个角色:</p>
<ul>
<li>Guest - 访客</li>
<li>Reporter - 报告者; 可以理解为测试员、产品经理等，一般负责提交issue等</li>
<li>Developer - 开发者; 负责开发</li>
<li>Master - 主人; 一般是组长，负责对Master分支进行维护</li>
<li>Owner - 拥有者; 一般是项目经理</li>
</ul>
<h3 id="权限"><a href="#权限" class="headerlink" title="权限"></a>权限</h3><p>不同角色，拥有不同权限，下面列出Gitlab各角色权限</p>
<h5 id="1-工程权限"><a href="#1-工程权限" class="headerlink" title="1. 工程权限"></a>1. 工程权限</h5><p>行为|Guest|Reporter|Developer|Master|Owner<br>|:–|:–<br>创建issue|✓|✓|✓|✓|✓<br>留言评论|✓|✓|✓|✓|✓<br>更新代码||✓|✓|✓|✓<br>下载工程||✓|✓|✓|✓<br>创建代码片段||✓|✓|✓|✓<br>创建合并请求|||✓|✓|✓<br>创建新分支|||✓|✓|✓<br>提交代码到非保护分支|||✓|✓|✓<br>强制提交到非保护分支|||✓|✓|✓<br>移除非保护分支|||✓|✓|✓<br>添加tag|||✓|✓|✓<br>创建wiki|||✓|✓|✓<br>管理issue处理者|||✓|✓|✓<br>管理labels|||✓|✓|✓<br>创建里程碑||||✓|✓<br>添加项目成员||||✓|✓<br>提交保护分支||||✓|✓<br>使能分支保护||||✓|✓<br>修改/移除tag||||✓|✓<br>编辑工程||||✓|✓<br>添加deploy keys||||✓|✓<br>配置hooks||||✓|✓<br>切换visibility level|||||✓<br>切换工程namespace|||||✓<br>移除工程|||||✓<br>强制提交保护分支|||||✓<br>移除保护分支|||||✓</p>
<p>PS: 关于保护分支的设置，可以进入Settings-&gt;Protected branches进行管理</p>
<h5 id="2-组权限"><a href="#2-组权限" class="headerlink" title="2. 组权限"></a>2. 组权限</h5><p>行为|Guest|Reporter|Developer|Master|Owner<br>|:–|:–<br>浏览组|✓|✓|✓|✓|✓<br>编辑组|||||✓<br>创建项目||||✓|✓<br>管理组成员|||||✓<br>移除组|||||✓</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/03/09/2016-03-09-linphone-iphone最新源码编译/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/03/09/2016-03-09-linphone-iphone最新源码编译/" itemprop="url">linphone-iphone最新源码编译</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-03-09T00:00:00+08:00">
                2016-03-09
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/音视频/" itemprop="url" rel="index">
                    <span itemprop="name">音视频</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>最近在解决音视频对讲的问题，发现原先那版linphone sdk存在比较多的问题，比如内存泄露、信令错乱、crash等等，通过github了解到，linphone sdk一直都在更新，于是想更新下linphone sdk. </p>
<h2 id="clone"><a href="#clone" class="headerlink" title="clone"></a>clone</h2><p>编译代码之前，肯定是先clone最新代码</p>
<pre>
git clone https://github.com/BelledonneCommunications/linphone-iphone --recursive
</pre>
更新完后发现跟原来的编译方式有了比较大的区别，更新完后编译步骤更清晰，更方便. 可以执行./prepare.py --help 查看帮助

## config
开始配置前，请使用`./prepare.py -c`清理上一次编译结果

#### 架构

目前linphone支持arm64、armv7、i386、x86_64架构，大家可以自行选择，一般只要armv64、armv7就行了，命令如下:
<pre>
./prepare.py arm64 armv7
</pre>

<h4 id="特性"><a href="#特性" class="headerlink" title="特性"></a>特性</h4><p>可以通过<code>./prepare.py -lf</code>来查看特性开关，若不想编译哪个模块，设为OFF，如我不需要编译MKV模块，就执行如下命令</p>
<pre>
./prepare.py -DENABLE_MKV=ON arm64 armv7
</pre>

<h2 id="build-sdk"><a href="#build-sdk" class="headerlink" title="build sdk"></a>build sdk</h2><p>config后，执行make进行编译</p>
<pre>
make
</pre>
若在编译过程中，遇到`GNU assembler not found, install/update gas-preprocessor`记得更新gas-preprocessor
<pre>
wget --no-check-certificate https://raw.githubusercontent.com/FFmpeg/gas-preprocessor/master/gas-preprocessor.pl && chmod +x gas-preprocessor.pl && sudo mv gas-preprocessor.pl /usr/local/bin
</pre>
PS: 不要去下载https://github.com/yuvi/gas-preprocessor这个，可能是比较旧；更新完后，记得将`/usr/local/bin`添加到PATH环境变量中
<pre>
export PATH=/usr/local/bin:$PATH
</pre>

<h2 id="build-app"><a href="#build-app" class="headerlink" title="build app"></a>build app</h2><p>编译完后sdk就可以开始编译app了，用xcode打开linphone.xcodeproj，更改证书，直接编译</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/02/25/2016-02-25-MacOSX命令行下快速切换WiFi/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/02/25/2016-02-25-MacOSX命令行下快速切换WiFi/" itemprop="url">MacOSX命令行下快速切换WiFi</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-02-25T00:00:00+08:00">
                2016-02-25
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/SHELL/" itemprop="url" rel="index">
                    <span itemprop="name">SHELL</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>办公室内有多个WiFi热点，由于工作内容的不同，需要不停地在多个WiFi下切换，而且有些WiFi还需要手动分配IP，如果是使用手动选择WiFi，再配置就非常不方便，因此，需要实现命令行下快速切换WiFi，首先列出一些tips</p>
<h3 id="1-Tips"><a href="#1-Tips" class="headerlink" title="1. Tips"></a>1. Tips</h3><ul>
<li><p>查看IP信息</p>
<pre>
ifconfig
</pre>
</li>
<li><p>查看DNS</p>
<pre>
networksetup -getdnsservers Wi-Fi
</pre>
</li>
<li><p>设置DNS</p>
<pre>
networksetup -setdnsservers Wi-Fi xxx.xxx.xxx.xxx
</pre>
</li>
<li><p>查看默认网关</p>
<pre>
netstat -nr|grep default
</pre>
</li>
<li><p>删除默认网关</p>
<pre>
sudo route delete default
</pre></li>
<li><p>添加默认网关</p>
<pre>
sudo route add default xxx.xxx.xxx.xxx
</pre>
</li>
<li><p>查看WiFi列表</p>
<pre>
ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
airport -s
</pre>
</li>
<li><p>获取当前WiFi信息</p>
<pre>
airport -I
</pre>
</li>
<li><p>手动配置IP</p>
<pre>
networksetup -setmanual networkservice  ip subnet router
或
networksetup -setmanualwithdhcprouter networkservice ip 
</pre>
</li>
<li><p>动态分配IP</p>
<pre>
networksetup -setdhcp networkservice
</pre>
</li>
<li><p>查看当前网络配置</p>
<pre>
networksetup -getinfo Wi-Fi
</pre>

</li>
</ul>
<h3 id="2-脚本化"><a href="#2-脚本化" class="headerlink" title="2. 脚本化"></a>2. 脚本化</h3><p>配置dd-wrt-xhw为手动分配IP为192.168.8.161</p>
<pre>
networksetup -setmanual Wi-Fi 192.168.8.161 255.255.255.0 192.168.8.1;networksetup -setairportnetwork en0 dd-wrt-xhw password
</pre>
配置22#3F-szjjyfb-AP1_5G为自动获取IP
<pre>
networksetup -setdhcp Wi-Fi;networksetup -setairportnetwork en0 22#3F-szjjyfb-AP1_5G password
</pre>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/02/18/2016-02-18-自己搭建OpenVPN/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/02/18/2016-02-18-自己搭建OpenVPN/" itemprop="url">自己搭建OpenVPN</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-02-18T00:00:00+08:00">
                2016-02-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/工具/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>去年买了vultr的VPS，使用shadowsocks可以在MAC上翻墙，但对于iPhone手机来说，不是特别好用，经常连不了，而且需要设置本地代理，想了想还有VPN这一条路，于是就想用OpenVPN来搭建服务器，过程蛮简单的，这里记录下.</p>
<h3 id="1-服务器搭建"><a href="#1-服务器搭建" class="headerlink" title="1. 服务器搭建"></a>1. 服务器搭建</h3><pre>
wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh
</pre>
PS: 按照提示来，最后输入用户名，完了后会在home目录生成.ovpn的文件，详细代码戳[这里](https://github.com/smallmuou/openvpn-install)

当然可以再次运行openvpn-install.sh进行用户添加、用户移除、卸载. 可以用ifconfig查看是否有tun
<pre>
...

tun0: flags=4305<up,pointopoint,running,noarp,multicast>  mtu 1500
        inet 10.8.0.1  netmask 255.255.255.0  destination 10.8.0.1
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 100  (UNSPEC)
        RX packets 5457  bytes 554757 (541.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6422  bytes 7135998 (6.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
...
</up,pointopoint,running,noarp,multicast></pre>

<h3 id="2-安装手机客户端"><a href="#2-安装手机客户端" class="headerlink" title="2. 安装手机客户端"></a>2. 安装手机客户端</h3><p>在国外Apple Store市场下载OpenVPN，并安装(国内市场是没有的)<br><img src="http://7ximmr.com1.z0.glb.clouddn.com/openvpn-ios-1.PNG" alt="image"></p>
<h3 id="3-手机客户端配置"><a href="#3-手机客户端配置" class="headerlink" title="3. 手机客户端配置"></a>3. 手机客户端配置</h3><ul>
<li><p>通过邮件发送.ovpn文件到手机邮箱，选择OpenVPN打开方式<br><img src="http://7ximmr.com1.z0.glb.clouddn.com/openvpn-ios-2.PNG" alt="image"></p>
</li>
<li><p>OpenVPN点击+，并Connect, 当显示为Connected则表示OK.<br><img src="http://7ximmr.com1.z0.glb.clouddn.com/openvpn-ios-3.png" alt="image"></p>
</li>
<li><p>这样我就可以用Twitter了<br><img src="http://7ximmr.com1.z0.glb.clouddn.com/openvpn-ios-4.png" alt="image"></p>
</li>
</ul>
<h3 id="4-问题"><a href="#4-问题" class="headerlink" title="4. 问题"></a>4. 问题</h3><p>有发现在某些WiFi下是翻不了，具体没去研究，后期再看下</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/02/17/2016-02-17-iptables要点/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/02/17/2016-02-17-iptables要点/" itemprop="url">iptables要点</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-02-17T00:00:00+08:00">
                2016-02-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>iptables是一个配置 Linux 内核防火墙的命令行工具. iptables是由tables组成，table由chains组成. </p>
<p>表名|功能描述|链|<br>|:–|:–|:–<br>raw|配置数据包,不会被系统跟踪|<br>filter|存放所有与防火墙相关操作的默认表|INPUT、OUTPUT、FORWARD<br>nat|网络地址转换|PREROUTING、POSTROUTING、OUTPUT<br>mangle|对特定数据包的修改<br>security|强制访问控制 网络规则</p>
<p><img src="https://i.v2ex.co/4WFXrnn2.png" alt="image"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/02/17/2016-02-17-UNIX命令行技巧/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/02/17/2016-02-17-UNIX命令行技巧/" itemprop="url">UNIX命令行技巧</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-02-17T00:00:00+08:00">
                2016-02-17
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/SHELL/" itemprop="url" rel="index">
                    <span itemprop="name">SHELL</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>命令行可以说是一个非常神奇的东西，喜欢MACOSX、Linux也是在于他们有强大的shell，本文将记录好用的技巧.</p>
<ul>
<li>brew - 软件安装</li>
<li>sox - 命令行录音</li>
<li>vim － 编辑工具</li>
<li>tcpdump - 命令行抓包工具</li>
<li>sed - 流编辑器</li>
<li>awk - 文本分析工具</li>
<li>clang - 编译工具</li>
<li>netstat - 查看网络状态，包含路由表信息</li>
<li>xcodebuild - 编译xcode工程</li>
<li>traceroute - 查看路由路线<pre>
traceroute -i www.baidu.com
</pre></li>
<li>lsof - 查看端口使用情况<pre>
lsof -i:80  #查看80断口
</pre></li>
<li>svn - 版本管理工具</li>
<li>git - 版本管理工具</li>
<li>rvictl - iOS设备网卡映射</li>
<li>afplay - 播放本地音乐</li>
<li>mplayer - 播放音视频</li>
<li>system_profiler - 查看系统软硬件配置</li>
<li>stunclient - 获取公网IP</li>
<li>screencapture - 屏幕抓拍</li>
<li>open - 打开文件</li>
<li>lipo - 查看可执行文件CPU架构</li>
<li>pbcopy - 复制到剪贴板</li>
<li>pbpaste - 黏贴</li>
<li>say - 播放文字</li>
<li>diskutil - 磁盘工具</li>
<li>wc - 统计行数</li>
<li>nslookup - 根据域名查看ip</li>
<li>osascript - 执行AppleScript、JavaScript<pre>
获取Safari的url
osascript -e 'tell application "Safari" to get URL of current tab of front window'
设置音量
osascript -e 'set volume 1'
</pre></li>
<li>airport - 获取热点信息<pre>
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
airport -s
</pre></li>
<li>networksetup - 网络设置<pre>
连接WIFI
networksetup -setairportnetwork en0 WIFI_SSID WIFI_PASSWORD
</pre></li>
<li>dsenableroot - root用户使能<br><pre><br>//Enable<br>dsenableroot</pre></li>
</ul>
<p>//Disable<br>dsenableroot -d<br></p>
<ul>
<li>&lt;(some command) 可以把某命令当成一个文件,系统临时创建一个fd,可以通过<code>echo &lt;(date)</code>验证</li>
<li>cat &lt;&lt;EOF - 了解什么叫 “<a href="http://zh.wikipedia.org/wiki/Here文档" target="_blank" rel="noopener">here documents</a>”</li>
<li>man ascii - 查看ascii码表</li>
<li>ssh user@server bash &lt; /path/to/local/script.sh - 远程执行本地脚本</li>
<li>python -m SimpleHTTPServer - 把当前目录设为HTTP服务目录，并启动http服务，端口8000</li>
<li>在 bash 里，使用 Ctrl-R 而不是上下光标键来查找历史命令</li>
<li><a href="https://www.ustack.com/blog/有关-shell-重定向那些你不知道的故事/" target="_blank" rel="noopener">重定向</a><pre>
0 - 输入
1 - 输出
2 - 错误
cat < test 等价于 cat 0< test
echo hel > test 等价于 echo hel 1> test
>/dev/null 2>&1 - 将1指向/dev/null，2指向1，即输出、错误都到/dev/null
2>&1 >/dev/null - 将2指向1，并把1指向/dev/null，这样输出到/dev/null，错误到屏幕
</pre>
</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/02/04/2016-02-04-命令行下获取TP-LINK路由器DHCP客户端列表/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/02/04/2016-02-04-命令行下获取TP-LINK路由器DHCP客户端列表/" itemprop="url">命令行下获取TP-LINK路由器DHCP客户端列表</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-02-04T00:00:00+08:00">
                2016-02-04
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/SHELL/" itemprop="url" rel="index">
                    <span itemprop="name">SHELL</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>需要实现一个需求：当我回到家时，音乐自动播放起来；关于这个需求有很多方式，比如声音识别、摄像头识别（仿生），当然也可以通过蓝牙、WIFI。声音与摄像识别的难度相对较大，后期再研究，因此就剩下蓝牙和WIFI，蓝牙的话，目前缺少蓝牙适配器，因此也暂时不考虑，那么就剩下WIFI了. 这里讲下总体思路，就是实时监控路由器中是否有我的手机在线，如果在线，则认为我在家. 那么问题就来了，如何知道我手机是否连到路由器. 这里有两个方法，方法一：为手机设置静态ip，不断ping这个ip；方法二：动态获取手机ip，不断ping这个ip.本文主要讲述如何动态获取手机ip.</p>
<h3 id="尝试1"><a href="#尝试1" class="headerlink" title="尝试1"></a>尝试1</h3><p>希望利用arp命令获取手机的ip，通过<code>arp -a</code>会得到如下结果：</p>
<pre>
bogon (192.168.12.1) at d0:c7:c0:8a:1a:7c on en0 ifscope [ethernet]
bogon (192.168.12.104) at (incomplete) on en0 ifscope [ethernet]
? (192.168.12.255) at (incomplete) on en0 ifscope [ethernet]
...
</pre>
PS：通过比对MAC地址判断哪个是我的手机，但是发现个问题，`arp -a`只能查看局域网内我电脑通信过的ip信息，对于未通信的终端是没有相应信息的，因此不一定能够获取到我手机的ip，而且还发现MAC地址有时是无法获取到，如上显示incomplete

### 尝试2
通过web方式查看路由器DHCP客户端列表，如图

![image](http://7ximmr.com1.z0.glb.clouddn.com/tplink-dhcp-client.png)

那么在命令行下如何实现呢?????????

##### 步骤
* 利用firefox或chrome抓取网页发送请求

![image](http://7ximmr.com1.z0.glb.clouddn.com/tplink-dhcp-client-catch.png)

* 利用curl模拟
<pre>
curl -s --header "Cookie:Authorization=Basic%20YWRtaW46ZXZpZGVv" http://192.168.12.1/userRpm/AssignedIpAddrListRpm.htm
</pre>
PS: Authorization后是密码信息，规则是: escape("Basic "+base64("admin:"+password))，javascript代码如下
<pre>
...
var password = $("pcPassword").value;    
var auth = "Basic "+Base64Encoding("admin:"+password);
document.cookie = "Authorization="+escape(auth)+";path=/";
...
</pre>
PS: 可以使用base64在命令行下进行编码，但要注意换行符，比如`echo "evideo" | base64`，此时将编码`evideo+换行`,需要使用`echo -n "evideo" | base64`
* 利用awk、sed进行后期处理
<pre>
curl -s --header "Cookie:Authorization=Basic%20YWRtaW46ZXZpZGVv" http://192.168.12.1/userRpm/AssignedIpAddrListRpm.htm|sed -n -e "/DHCPDynList/,/)/p"|sed '1d;$d'
</pre>
通过上面的curl得到如下结果:
<pre>
"eVideos-Mini", "A8-20-66-4A-CB-B6", "192.168.12.101", "01:18:48", 
"android-6ca5b9c4644c86ec", "34-23-BA-67-ED-C6", "192.168.12.149", "01:58:49", 
...
</pre>
* 获取对应的客户端ip，并进行ping，ping通的话表示在线，否则表示不在线
<pre>
curl -s --header "Cookie:Authorization=Basic%20YWRtaW46ZXZpZGVv" http://192.168.12.1/userRpm/AssignedIpAddrListRpm.htm|awk -F[\ ,] '/smallmuou/{print $5}'|sed 's/"//g'|xargs ping -c 3
</pre>
PS：smallmuou是我的手机名

当我手机在线会得到如下信息：
<pre>
PING 192.168.12.109 (192.168.12.109): 56 data bytes
64 bytes from 192.168.12.109: icmp_seq=0 ttl=64 time=810.294 ms
64 bytes from 192.168.12.109: icmp_seq=1 ttl=64 time=26.548 ms
64 bytes from 192.168.12.109: icmp_seq=2 ttl=64 time=185.024 ms
</pre>

<p>当我手机不在线会得到如下信息：</p>
<pre>
PING 192.168.12.109 (192.168.12.109): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
</pre>

<h3 id="后续工作"><a href="#后续工作" class="headerlink" title="后续工作"></a>后续工作</h3><p>以上已经讲出了本文的所有内容，对于本文开头提出的需求，这里还有个坑，由于iPhone手机在休眠情况下，也是ping不通的，因此需要通过加上额外的信息才能保证此方式的可行性，比如时间信息.</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/blog/page/12/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/blog/">1</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/12/">12</a><span class="page-number current">13</span><a class="page-number" href="/blog/page/14/">14</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/20/">20</a><a class="extend next" rel="next" href="/blog/page/14/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">smallmuou</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">197</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/smallmuou" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-globe"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">smallmuou</span>

  
</div>

    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

    <span id="busuanzi_container_site_pv">总访问量<span id="busuanzi_value_site_pv"></span>次</span>
    <span class="post-meta-divider">|</span>



  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  

  

  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
